feat(cf-workers): add CORS utility and auto-decode request paths#37
Merged
alukach merged 1 commit intoMay 21, 2026
Merged
Conversation
- add_cors_headers() sets permissive CORS headers for browser-accessible S3-compatible read-only proxies - RequestParts::from_web_sys() now percent-decodes the URL path automatically These eliminate two common boilerplate patterns in consumer apps. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
alukach
added a commit
that referenced
this pull request
May 21, 2026
* feat(cf-workers): add RequestParts for ergonomic request extraction Introduces RequestParts struct that extracts owned HTTP metadata from a web_sys::Request and provides as_request_info() to borrow it for gateway dispatch. Eliminates 8 lines of manual parsing boilerplate per handler. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor(cf-workers): trim public exports to essential API surface Reduce public exports from 8 to 2 (response_from_gateway, headermap_from_js). Remove dead code (xml_response, s3_error_response) and make internal helpers pub(crate). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor(cf-workers): add WsHeaders newtype for ergonomic header conversion Introduces WsHeaders wrapper around web_sys::Headers with From<&HeaderMap>, working around orphan rule constraints. Replaces 4 manual header conversion blocks in backend.rs and response.rs, and removes the now-unused headers_to_js. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor(cf-workers): encapsulate JsBody with private field and accessor methods Makes JsBody's inner Option<ReadableStream> private to prevent accidental mutation. Adds JsBody::new() constructor and stream() accessor. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor(cf-workers): replace response_from_gateway with GatewayResponseExt trait Replaces the free function with an extension trait on GatewayResponse, enabling method syntax: `result.into_web_sys()`. Improves discoverability via IDE autocomplete on the GatewayResponse type. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: update crate-layout to reflect cf-workers ergonomic improvements Documents RequestParts, GatewayResponseExt, JsBody, and WsHeaders in the cf-workers crate description. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: add .worktrees to gitignore * refactor: make Body an associated type on ProxyBackend (#38) Replaces the generic Body parameter on forward() with an associated type, eliminating runtime downcasts via Box<dyn Any>. Body type mismatches are now caught at compile time. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat(cf-workers): add CORS utility and auto-decode request paths (#37) - add_cors_headers() sets permissive CORS headers for browser-accessible S3-compatible read-only proxies - RequestParts::from_web_sys() now percent-decodes the URL path automatically These eliminate two common boilerplate patterns in consumer apps. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: add HandlerAction::response_headers_mut() for ergonomic header injection (#36) Middleware that adds response headers (CORS, Server-Timing, etc.) no longer needs to match on all three HandlerAction variants manually. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: use MaybeSend/MaybeSync on BucketRegistry and CredentialRegistry (#35) This allows WASM implementations to use !Send types (like worker::Fetch and the CF Cache API) directly, eliminating the need for spawn_local + oneshot channel bridges. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: merge fix --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
add_cors_headers()sets permissive CORS headers for browser-accessible S3 proxiesRequestParts::from_web_sys()now percent-decodes the URL path automaticallyTest plan
cargo check --target wasm32-unknown-unknown -p multistore-cf-workerspasses🤖 Generated with Claude Code